package com.cgwx.tmservice.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import io.swagger.annotations.Api;

/**
 * @author GaoWei
 * @Date 2023/8/8 - 17:25
 */

@Api(tags = "读取Excel时，遥测解析值转换器")
public class TmAnalyticConverter implements Converter {
    @Override
    public Class supportJavaTypeKey() {
        return null;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public Object convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) {
        int tmAnalyticType = 0;
        switch (cellData.toString()) {
            case "原码显示":
                tmAnalyticType = 0;
                break;
            case "十进制显示":
                tmAnalyticType = 1;
                break;
            case "公式":
                tmAnalyticType = 2;
                break;
            case "状态码(十六进制)":
                tmAnalyticType = 3;
                break;
            case "状态码(十进制)":
                tmAnalyticType = 4;
                break;
            case "状态码(二进制)":
                tmAnalyticType = 5;
                break;
            case "时间":
                tmAnalyticType = 6;
                break;
            case "不处理":
                tmAnalyticType = 7;
                break;
            case "32位单精度浮点数":
                tmAnalyticType = 8;
                break;
        }
        return tmAnalyticType;
    }

    @Override
    public CellData convertToExcelData(Object o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) {
        return null;
    }
}
